package pack1;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * Created by jack on 2017/7/3.
 */
//声明当前类是一个配置类
@Configuration
//自动扫描包名下所有使用@Component、@Service、@Repository和@Controller的类，并注册为Bean
@ComponentScan("pack1")
public class PrePostConfig {

    //initMethod和destroyMethod指定BeanWayService类的init和destroy方法在构造之后、Bean销毁之前执行。
    @Bean(initMethod="init",destroyMethod="destroy") //1
    BeanWayService beanWayService()
    {
        System.out.println("PrePostConfig::new BeanWayService()");
        return new BeanWayService();
    }

    @Bean
    JSR250WayService jsr250WayService()
    {
        System.out.println("PrePostConfig::new JSR250WayService()");
        return new JSR250WayService();
    }
}
